/*
 * Copyright (C) 2023 xuexiangjys(xuexiangjys@163.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package com.xuexiang.templateproject.widget;

//import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.xuexiang.templateproject.R;
//import com.jcds.learneasy.entity.Box;
import com.xuexiang.templateproject.bean.Box;

import java.util.LinkedHashMap;
//import kotlin.Metadata;
import kotlin.jvm.internal.Intrinsics;
//import org.jetbrains.anko.CustomViewPropertiesKt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public final class BoxView extends RelativeLayout {
    @NotNull

    /* renamed from: a  reason: collision with root package name */
    public Box mBox;

    /* renamed from: b  reason: collision with root package name */
    public int mWidth;

    /* renamed from: c  reason: collision with root package name */
    public int mHeight;
    @Nullable

    /* renamed from: d  reason: collision with root package name */
    public OnViewClickListener f4390d;
    @Nullable

    /* renamed from: e  reason: collision with root package name */
    public OnViewEditClickListener f4391e;
    @Nullable

    /* renamed from: f  reason: collision with root package name */
    public OnMergeViewClickListener f4392f;

    /* renamed from: g  reason: collision with root package name */
    public boolean mCheck;
    @Nullable

    /* renamed from: h  reason: collision with root package name */
    public ImageView f4394h;
    @Nullable

    /* renamed from: i  reason: collision with root package name */
    public TextView f4395i;
    @Nullable

    /* renamed from: j  reason: collision with root package name */
    public TextView f4396j;
    @Nullable

    /* renamed from: k  reason: collision with root package name */
    public TextView f4397k;

    /* renamed from: l  reason: collision with root package name */
    public boolean mEdit;

    /* renamed from: m  reason: collision with root package name */
    public int mTempHeight;

    public interface OnMergeViewClickListener {
        void onMergeClick(@NotNull Box box);
    }

    public interface OnViewClickListener {
        void onClick(@NotNull Box box, boolean z);
    }

    public interface OnViewEditClickListener {
        void onEditClick();
    }

    public final class d implements View.OnClickListener {
        public d() {
        }

        @Override // android.view.View.OnClickListener
        public void onClick(@Nullable View view) {
            BoxView boxView = BoxView.this;
            boxView.setCheck(!boxView.f());
            BoxView boxView2 = BoxView.this;
            boxView2.setEdit(!boxView2.g());
            BoxView.this.j();
            OnViewClickListener bVar = BoxView.this.f4390d;
            if (bVar != null) {
                bVar.onClick(BoxView.this.getBox(), BoxView.this.f());
            }
        }
    }

    public final class e implements View.OnLongClickListener {
        public e() {
        }

        @Override // android.view.View.OnLongClickListener
        public boolean onLongClick(@Nullable View view) {
            OnViewEditClickListener cVar = BoxView.this.f4391e;
            if (cVar != null) {
                cVar.onEditClick();
                return true;
            }
            return true;
        }
    }

    public final class f implements View.OnClickListener {
        public f() {
        }

        @Override // android.view.View.OnClickListener
        public void onClick(@Nullable View view) {
            OnViewEditClickListener cVar = BoxView.this.f4391e;
            if (cVar != null) {
                cVar.onEditClick();
            }
        }
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public BoxView(@NotNull Box box, @Nullable Context context, int i2, int i3) {
        super(context, null);
        Intrinsics.checkNotNullParameter(box, "box");
        new LinkedHashMap();
        this.mBox = box;
        this.mWidth = i2;
        this.mHeight = i3;
        d();
        c();
    }

    public static final void e(BoxView this$0, View view) {
        Intrinsics.checkNotNullParameter(this$0, "this$0");
        OnMergeViewClickListener aVar = this$0.f4392f;
        if (aVar != null) {
            aVar.onMergeClick(this$0.mBox);
        }
    }

    public final void c() {
        setOnClickListener(new d());
        setOnLongClickListener(new e());
    }

    public final void d() {
        /*
            Method dump skipped, instructions count: 590
            To view this dump change 'Code comments level' option to 'DEBUG'
        */
        throw new UnsupportedOperationException("Method not decompiled: com.jcds.learneasy.widget.BoxView.d():void");
    }

    public final boolean f() {
        return this.mCheck;
    }

    public final boolean g() {
        return this.mEdit;
    }

    @NotNull
    public final Box getBox() {
        return this.mBox;
    }

    public final int getBoxHeight() {
        return this.mHeight;
    }

    public final int getBoxWidth() {
        return this.mWidth;
    }

    public final int getNum() {
        TextView textView = this.f4395i;
        return Integer.parseInt(String.valueOf(textView != null ? textView.getText() : null));
    }

    public final int getTempHeight() {
        return this.mTempHeight;
    }

    public final void i() {
        removeView(this.f4397k);
    }

    public final void j() {
        Drawable drawable = null;
        if (this.mCheck) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                drawable = getContext().getDrawable(R.drawable.bg_box_border_checked);
            }
        } else {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                drawable = getContext().getDrawable(R.drawable.bg_box_border);
            }
        }
        if(drawable!=null)
        setBackgroundDrawable(drawable);
        TextView textView = this.f4396j;
        if (textView != null) {
            textView.setVisibility(this.mEdit ? View.VISIBLE : View.GONE);
        }
        ImageView imageView = this.f4394h;
        if (imageView != null) {
            imageView.setVisibility(this.mCheck ? View.GONE : View.VISIBLE);
        }
        TextView textView2 = this.f4395i;
        if (textView2 == null) {
            return;
        }
        textView2.setVisibility(this.mCheck ? View.VISIBLE : View.GONE);
    }

    @Override // android.widget.RelativeLayout, android.view.View
    public void onMeasure(int i2, int i3) {
        super.onMeasure(i2, i3);
        View.MeasureSpec.getSize(i2);
        View.MeasureSpec.getSize(i3);
    }

    public final void setBox(@NotNull Box box) {
        Intrinsics.checkNotNullParameter(box, "<set-?>");
        this.mBox = box;
    }

    public final void setBoxHeight(int i2) {
        this.mHeight = i2;
    }

    public final void setBoxWidth(int i2) {
        this.mWidth = i2;
    }

    public final void setCheck(boolean z) {
        this.mCheck = z;
    }

    public final void setEdit(boolean z) {
        this.mEdit = z;
    }

    public final void setNum(int i2) {
        TextView textView = this.f4395i;
        if (textView == null) {
            return;
        }
        textView.setText(String.valueOf(i2));
    }

    public final void setOnMergeViewClickListener(@NotNull OnMergeViewClickListener onMergeViewClickListener) {
        Intrinsics.checkNotNullParameter(onMergeViewClickListener, "onMergeViewClickListener");
        this.f4392f = onMergeViewClickListener;
    }

    public final void setOnViewClickListener(@NotNull OnViewClickListener onViewClickListener) {
        Intrinsics.checkNotNullParameter(onViewClickListener, "onViewClickListener");
        this.f4390d = onViewClickListener;
    }

    public final void setOnViewEditClickListener(@NotNull OnViewEditClickListener onViewEditClickListener) {
        Intrinsics.checkNotNullParameter(onViewEditClickListener, "onViewEditClickListener");
        this.f4391e = onViewEditClickListener;
    }

    public final void setTempHeight(int i2) {
        this.mTempHeight = i2;
    }
}